function Component(option: { id: string }) {
  return (target: Function & typeof TestClass) => {
    target.prototype.id = 300
    target.elementId = option.id
  }
}

/**
 * @param target 当前的原型对象
 * @param propertyKey 方法接受参数的关键字
 * @param propertyDesriptor 装饰器装饰的方法描述，
 */
function MethodTest(target: Object, propertyKey: string, propertyDesriptor: PropertyDescriptor) {
  console.log(target)
  console.log(propertyKey)
  console.log(propertyDesriptor)
  propertyDesriptor.value = function (...args: any[]) {
    return `Hello ${args}`
  }
}

function PropTest(target: Object, propertyName: string) {
  let value: number;

  const getter = () => {
    console.log(`获取值${value}`)
    return value
  }

  const setter = (newVal: number) => {
    console.log(`设置值${newVal}`)
    value = newVal
  }

  Object.defineProperty(target, propertyName, { get: getter, set: setter })
}

function MethodPropTest(target: Object, propertyName: string, index: number) {
  console.log('-------')
  console.log(target)
  console.log(propertyName)
  console.log(index)
  console.log('-------')
}

@Component({ id: '200' })
export class TestClass {
  static elementId: string;

  @PropTest
  id: number

  @MethodTest
  printId(prefix: string = ''): string {
    return prefix + this.id
  }

  gateArea(width: number, @MethodPropTest height: number) {
    return width * height
  }
}

const _test = new TestClass()
const _res = _test.printId('22')
console.log(_res)
console.log(_test.id)